﻿namespace Blackbird.Common
{
    public class DenseGraph<T> : Graph<T>
    {
        private T[] _storageArray;

        protected T[] StorageArray
        {
            get
            {
                if (_storageArray == null)
                    InitializeStorage();
                return _storageArray;
            }
        }

        public DenseGraph()
        {
        }

        public DenseGraph(params int[] dimensionExtents)
            : base(dimensionExtents)
        {
        }

        protected internal override T GetItemByIndex(ulong index)
        {
            return StorageArray[index];
        }

        protected internal override void SetItemByIndex(T item, ulong index)
        {
            StorageArray[index] = item;
        }

        public override void InitializeStorage() {
            _storageArray = new T[MaximumItemCount];
        }

    }
}